﻿Jx.ready(function () {
    var name = Jx("#txtName");
    var pass = Jx("#txtPass");
    var code = Jx("#txtCode");
    var mess = Jx(".message");

    Jx(name, "form")[0].focus();

    Jx("button").on("click", function () {
        mess.hide().text("");
        if (!name.val()) {
            mess.show('block').text("用户名不能为空.");
            Jx(name,"form")[0].focus();
            return false;
        } else if (!pass.val()) {
            mess.show('block').text("密码不能为空.");
            Jx(pass, "form")[0].focus();
            return false;
        } else if (!code.val()) {
            mess.show('block').text("验证码不能为空.");
            Jx(code, "form")[0].focus();
            return false;
        }

       //Jx("button").attr("disabled", true);
        Jx.ajax({
            url: "/Admin/Login.aspx",
            data: {
                name: name.val(),
                pass: pass.val(),
                code: code.val()
            },
            type:"post",
            dataType: "json",
            error: function () {
                
            },
            success: function (result) {
                if (result.message) {
                    mess.show('block').text(result.message);
                } else {
                    window.location.href = result.url;
                }
            }
        });
    });
});